package com.yuanrui.practice.server.subject;


import com.yuanrui.practice.api.vo.PracticeSubjectOptionVO;
import com.yuanrui.practice.server.dao.SubjectJudgeDao;
import com.yuanrui.practice.server.entity.po.SubjectJudgePO;
import com.yuanrui.practice.server.enums.SubjectInfoTypeEnum;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.LinkedList;
import java.util.List;

/**
 * 判断题目策略类
 */
@Component
public class JudgeTypeHandler implements SubjectTypeHandler {
    @Resource
    private SubjectJudgeDao subjectJudgeDao;

    @Override
    public SubjectInfoTypeEnum getSubjectType() {
        return SubjectInfoTypeEnum.JUDGE;
    }



    @Override
    public List<PracticeSubjectOptionVO> query(Long subjectId) {
        List<PracticeSubjectOptionVO> practiceSubjectOptionVOS = new LinkedList<>();
        SubjectJudgePO subjectJudgePO = subjectJudgeDao.selectBySubjectId(subjectId);
        if (subjectJudgePO == null){
            return practiceSubjectOptionVOS;
        }
        PracticeSubjectOptionVO practiceSubjectOptionVO = new PracticeSubjectOptionVO();
        practiceSubjectOptionVO.setIsCorrect(subjectJudgePO.getIsCorrect());
        practiceSubjectOptionVOS.add(practiceSubjectOptionVO);
        return practiceSubjectOptionVOS;
    }

}
